import { Injectable, Logger } from '@nestjs/common';
import { CreateSystemUserDto } from './dto/create-system-user.dto';
import { UpdateSystemUserDto } from './dto/update-system-user.dto';
import { InjectRepository } from '@nestjs/typeorm';
import { CouponInfo } from '../coupon/coupon_info/entities/coupon_info.entity';
import { getConnection, Repository } from 'typeorm';
import { SysUser } from '../../auth/entities/auth.entity';
import { SuccessResponse } from '../../util/ResultResponse';

@Injectable()
export class SystemUserService {
  create(createSystemUserDto: CreateSystemUserDto) {
    return 'This action adds a new systemUser';
  }
  private readonly logger: Logger = new Logger('SystemUserService');

  /**
   * 你是我的小宝贝
   * @param sysUserRepository
   */
  constructor(
    @InjectRepository(SysUser)
    private readonly sysUserRepository: Repository<SysUser>,
  ) {}
 async findAll(): Promise<SuccessResponse<SysUser[]>> {


   return   await this.sysUserRepository.find().then((users) => {
      return {
        code: 0,
        data: users,
        message: '成功',
      };
    });
  }

  findOne(id: number) {
    return `This action returns a #${id} systemUser`;
  }

  update(id: number, updateSystemUserDto: UpdateSystemUserDto) {
    return `This action updates a #${id} systemUser`;
  }

  remove(id: number) {
    return `This action removes a #${id} systemUser`;
  }
}
